package pages

import (
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Switch() {
	@layouts.DocsLayout(
		"Switch",
		"Two-state button that can be switched on or off.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				Text: "Examples",
				ID:   "examples",
				Children: []modules.TableOfContentsItem{
					{
						Text: "Form",
						ID:   "form",
					},
				},
			},
			{
				ID:   "api",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "switch",
						Text: "Switch",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Switch",
			Description: templ.Raw("Two-state button that can be switched on or off."),
			Tailwind:    true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Switch",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				ShowcaseFile:    showcase.SwitchDefault(),
				PreviewCodeFile: "switch_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "switch",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Examples",
				ID:    "examples",
			}) {
				@modules.ExampleWrapper(modules.ExampleWrapperProps{
					SectionName:     "Form",
					ShowcaseFile:    showcase.SwitchForm(),
					PreviewCodeFile: "switch_form.templ",
					ID:              "form",
				})
			}
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api",
			}) {
				@modules.APILegend()
				<div id="switch" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Switch",
						Description: "Two-state button component that can be switched on or off.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the switch element.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the switch.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the switch element.",
								Required:    false,
							},
							{
								Name:        "Name",
								Type:        "string",
								Default:     "",
								Description: "Name attribute for form submission.",
								Required:    false,
							},
							{
								Name:        "Value",
								Type:        "string",
								Default:     "on",
								Description: "Value sent when the switch is checked.",
								Required:    false,
							},
							{
								Name:        "Checked",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the switch is initially checked.",
								Required:    false,
							},
							{
								Name:        "Disabled",
								Type:        "bool",
								Default:     "false",
								Description: "Whether the switch is disabled and non-interactive.",
								Required:    false,
							},
						},
					})
				</div>
			}
		}
	}
}
